package com.feiclub.subject.common.entity;


import com.feiclub.subject.common.enums.ResultCodeENUM;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class Result<T> {
    private Boolean success;
    private Integer code;
    private String msg;
    private T data;

    public static <T> Result success() {
        Result result = new Result();
        result.setSuccess(true);
        result.setCode(ResultCodeENUM.SUCCESS.getCode());
        result.setMsg(ResultCodeENUM.SUCCESS.getDesc());
        return result;
    }

    public static <T> Result success(T data) {
        Result result = new Result();
        result.setSuccess(true);
        result.setCode(ResultCodeENUM.SUCCESS.getCode());
        result.setMsg(ResultCodeENUM.SUCCESS.getDesc());
        result.setData(data);
        return result;
    }

    public static  Result error() {
        Result result = new Result();
        result.setSuccess(false);
        result.setCode(ResultCodeENUM.FAIL.getCode());
        result.setMsg(ResultCodeENUM.FAIL.getDesc());
        return result;
    }
    public static <T> Result error(T data) {
        Result result = new Result();
        result.setSuccess(false);
        result.setCode(ResultCodeENUM.FAIL.getCode());
        result.setMsg(ResultCodeENUM.FAIL.getDesc());
        result.setData(data);
        return result;
    }
}
